import Vue from 'vue'
import App from './App'
import '../static/vant/common/index.wxss'

import utils from "./utils/index"

import store from './store/index'
Vue.prototype.$store = store

for (const key in utils) {
  Vue.prototype[key] = utils[key];
}

import navTitle from './component/navTitle.vue'
Vue.component('navTitle', navTitle)

import loadEnd from './component/loadEnd.vue';
Vue.component('loadEnd', loadEnd);

const globalData = {
  height: '',
  lineHeight: ''
}
function calcNavBarInfo () {
  // 获取系统信息
  const systemInfo = wx.getSystemInfoSync();
  // 胶囊按钮位置信息
  const menuButtonInfo = wx.getMenuButtonBoundingClientRect();
  // 导航栏高度 = 状态栏到胶囊的间距（胶囊上坐标位置-状态栏高度） * 2 + 胶囊高度 + 状态栏高度
  const navBarHeight = (menuButtonInfo.top - systemInfo.statusBarHeight) * 2 + menuButtonInfo.height + systemInfo.statusBarHeight;
  // 状态栏和菜单按钮(标题栏)之间的间距
  // 等同于菜单按钮(标题栏)到正文之间的间距（胶囊上坐标位置-状态栏高度）
  const menuBottom = menuButtonInfo.top - systemInfo.statusBarHeight;
  const menuTop = menuButtonInfo.top;
  // 菜单按钮栏(标题栏)的高度
  const menuHeight = menuButtonInfo.height;
  globalData.height = `${navBarHeight + menuBottom}px`;
  globalData.lineHeight = `${navBarHeight + menuTop}px`;
  globalData.menuTop = `${menuTop}px`;
}
calcNavBarInfo();
Vue.prototype.globalData = globalData;

Vue.config.productionTip = false
App.mpType = 'app'

const app = new Vue(App)
app.$mount()
